#include "bsp_buzzer.h"
#include "main.h"
#include "tim.h"

extern TIM_HandleTypeDef htim4;

/**
 * @brief 打开蜂鸣器
 * @param  psc              预分频值
 * @param  pwm              PWM值
 * @author CT Y
 * @date 2023-04-29
 */
void buzzer_on(uint16_t psc, uint16_t pwm)
{
    __HAL_TIM_PRESCALER(&htim4, psc);
    __HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_2, pwm);

}


/**
 * @brief 关闭蜂鸣器
 * @author CT Y
 * @date 2023-04-29
 */
void buzzer_off(void)
{
    __HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_2, 0);
}